import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Microsoft
 * Date: 2022-11-08
 * Time: 16:52
 */
public class Test {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //生成随机数字
        Random random = new Random();
        int randNum = random.nextInt(100);  //[0,100)
        System.out.println(randNum);

        //猜数字
        while (true) {
            System.out.println("请输入你要猜的数字");
            int scanNum = scan.nextInt();
            if (scanNum > randNum) {
                System.out.println("猜大了");
            }else if (scanNum < randNum) {
                System.out.println("猜小了");
            }else {
                System.out.println("猜对了");
                break;
            }
        }
    }


    public static void main6(String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNextInt()) {
            int n = scan.nextInt();
            int m = scan.nextInt();
            System.out.println("n + m =  "+(m+n));
        }
    }

    public static void main5(String[] args) {
        Scanner scan = new Scanner(System.in);

        System.out.println("请输入年龄");
        int age = scan.nextInt();
        System.out.println(age);

        scan.nextLine();//清空缓冲区的回车

        System.out.println("请输入姓名");
        String name = scan.nextLine();
        System.out.println(name);

    }


    public static void main4(String[] args) {

        Scanner scan = new Scanner(System.in);
        String name = scan.next();
        System.out.println(name);
        String name2 = scan.next();
        System.out.println(name2);
//        String str2 = scan.next();
//        System.out.println(str2);
//        next相较于nextLine有一个很大的缺点，遇到空格，停止扫描
    }

    public static void main3(String[] args) {
        Scanner scan = new Scanner(System.in);

        System.out.println("请输入你的姓名");
        String str = scan.nextLine();
        System.out.println(str);

        System.out.println("请输入你的年龄");
        int n = scan.nextInt();
        System.out.println(n);

        System.out.println("请输入你的工资");
        float wage = scan.nextFloat();
        System.out.println(wage);

        scan.close();

    }



    public static void main2(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        System.out.println(n);
    }



    public static void main1(String[] args) {
        System.out.println("输出切换行");
        System.out.print("输出且不换行");
        System.out.printf("%s\n","格式化输出！和C语言一样!");
    }
    //-------------
    //编译器运行结果为
    //输出切换行
    //输出且不换行格式化输出！和C语言一样!
}
